﻿@using Smartstore.Admin.Models.Orders
@using Smartstore.Core.Checkout.Orders

@model DashboardLatestOrdersModel

<div class="report">
    <div class="report-title-row">
        <div class="report-title">@T("Admin.SalesReport.LatestOrders")</div>
    </div>
    <div class="table-responsive table-dashboard table-hover table-prevent-overflow">
        <table class="table small">
            <thead>
                <tr>
                    <th class="display-row" style="width: 10%">#</th>
                    <th class="display-row" style="width: 15%">@T("Account.CustomerOrders.OrderStatus")</th>
                    <th class="display-row text-center px-3 d-none d-sm-table-cell" style="width: 10%">@T("Admin.Catalog.Categories.Products")</th>
                    <th class="display-row text-right" style="width: 15%; padding-right: 2rem">@T("Common.Amount")</th>
                    <th class="display-row d-none d-sm-table-cell" style="width: 20%;">@T("Account.CustomerOrders.OrderDate")</th>
                    <th class="display-row" style="width: 25%">@T("Admin.Customers.Reports.BestBy.Fields.Customer")</th>
                </tr>
            </thead>
            <tbody>
                @foreach (var x in Model.LatestOrders)
                {
                    <tr class="order-row" index="@x.OrderId">
                        <td class="display-row" title="@x.OrderId">
                            <a asp-action="Edit" asp-controller="Order" asp-route-id="@x.OrderId">@x.OrderNumber</a>
                        </td>
                        @if (x.OrderState == OrderStatus.Pending)
                        {
                            <td class="display-row d-flex align-items-center" title="@T("Enums.OrderStatus.Pending")">
                                <div class="bg-warning indicator"></div>
                                <a asp-action="Edit" asp-controller="Order" asp-route-id="@x.OrderId" class="pl-2 text-truncate">@T("Enums.OrderStatus.Pending")</a>
                            </td>
                        }
                        else if (x.OrderState == OrderStatus.Processing)
                        {
                            <td class="display-row d-flex align-items-center" title="@T("Enums.OrderStatus.Processing")">
                                <div class="bg-success indicator"></div>
                                <a asp-action="Edit" asp-controller="Order" asp-route-id="@x.OrderId" class="pl-2 text-truncate">@T("Enums.OrderStatus.Processing")</a>
                            </td>
                        }
                        else if (x.OrderState == OrderStatus.Complete)
                        {
                            <td class="display-row d-flex align-items-center" title="@T("Enums.OrderStatus.Complete")">
                                <div class="bg-primary indicator"></div>
                                <a asp-action="Edit" asp-controller="Order" asp-route-id="@x.OrderId" class="pl-2 text-truncate">@T("Enums.OrderStatus.Complete")</a>
                            </td>
                        }
                        else if (x.OrderState == OrderStatus.Cancelled)
                        {
                            <td class="display-row d-flex align-items-center" title="@T("Enums.OrderStatus.Cancelled")">
                                <div class="bg-danger indicator"></div>
                                <a asp-action="Edit" asp-controller="Order" asp-route-id="@x.OrderId" class="pl-2 text-truncate">@T("Enums.OrderStatus.Cancelled")</a>
                            </td>
                        }

                        <td class="display-row text-center d-none d-sm-table-cell" title="@x.ProductsTotal">@x.ProductsTotal</td>
                        <td class="display-row text-right" style="padding-right: 2rem" title="@x.TotalAmount @T("Tax.InclVAT")">@x.TotalAmount</td>
                        <td class="display-row d-none d-sm-table-cell" title="@x.Created">@x.Created</td>

                        <td class="display-row" title="@x.CustomerDisplayName">
                            <a asp-action="Edit" asp-controller="Customer" asp-route-id="@x.CustomerId">@x.CustomerDisplayName</a>
                        </td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
</div>